package kk.yy.myaccount.main.adapter;

import android.accounts.Account;
import android.graphics.Color;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import kk.yy.myaccount.R;
import kk.yy.myaccount.main.model.AccountItem;

public class AccountAdapter extends BaseMultiItemQuickAdapter<AccountItem, BaseViewHolder> {

    public AccountAdapter(List data) {
        super(data);
        addItemType(AccountItem.OUT, R.layout.item_account);
        addItemType(AccountItem.INPUT, R.layout.item_account);
    }

    @Override
    protected void convert(BaseViewHolder helper, AccountItem item) {
        switch (helper.getItemViewType()) {
            case AccountItem.OUT:
                TextView price=(TextView)helper.getView(R.id.account_price);
                price.setTextColor(Color.RED);
                helper.setText(R.id.account_content,item.getAccountContent());
                helper.setText(R.id.account_price,"-"+String.valueOf(item.getPrice()));
                helper.setText(R.id.account_time,item.getAccountTime());
                break;
            case AccountItem.INPUT:
                TextView price2=(TextView)helper.getView(R.id.account_price);
                price2.setTextColor(Color.GREEN);
                helper.setText(R.id.account_content,item.getAccountContent());
                helper.setText(R.id.account_price,"+"+String.valueOf(item.getPrice()));
                helper.setText(R.id.account_time,item.getAccountTime());
                break;
        }
    }

}
